package dragon.core.db;

import dragon.core.util.StringUtils;

public class TableMeta implements Cloneable {

	@Override
	public Object clone() throws CloneNotSupportedException {
		TableMeta table = (TableMeta) super.clone();
		table.columns = table.columns.clone();
		for (int i = 0; i < table.columns.length; i++) {
			table.columns[i] = (ColumnMeta) table.columns[i].clone();
		}
		return table;
	}

	@Override
	public String toString() {
		if (schemaname != null && !StringUtils.isEmpty(schemaname)) {
			return schemaname + "." + name;
		} else {
			return name;
		}
	}

	/**
	 * 对应的class名
	 */
	private String className;

	/**
	 * Schema
	 */
	private String schemaname;

	/**
	 * 表名
	 */
	private String name;

	/**
	 * 注释
	 */
	private String comment;

	/**
	 * 字段
	 */
	private ColumnMeta[] columns;

	public ColumnMeta[] getColumns() {
		return columns;
	}

	public void setColumns(ColumnMeta[] columns) {
		this.columns = columns;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	/**
	 * @return the schemaname
	 */
	public String getSchemaname() {
		return schemaname;
	}

	/**
	 * @param schemaname
	 *            the schemaname to set
	 */
	public void setSchemaname(String schemaname) {
		this.schemaname = schemaname;
	}
}
